package com.buercorp.wangyu.socket;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 表示IP的类InetAddress
 * @author liyiyu
 */
public class Test01 {
    public static void main(String[] args) throws UnknownHostException {
        // 确定主机名称的IP地址 主机名称可以是机器名称 也可以是IP地址
        InetAddress address = InetAddress.getByName("MS-ZFXFFGYIDJPM");
        System.out.println(address);

        // 获取此IP地址的主机名
        String hostName = address.getHostName();
        System.out.println(hostName);

        // 返回文本显示的IP地址字符串
        String ip = address.getHostAddress();
        System.out.println(ip);

        /**
         * MS-ZFXFFGYIDJPM/192.168.10.137
         * MS-ZFXFFGYIDJPM
         * 192.168.10.137
         */
    }
}
